package com.db.williamchart.pointtooltip;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.db.williamchart.Tooltip;

public class PointTooltip implements Tooltip {

    private View tooltipView;
    private int drawableRes = R.drawable.circle_point;

    @Override
    public void onCreateTooltip(ViewGroup parentView) {
        tooltipView = LayoutInflater.from(parentView.getContext())
                .inflate(R.layout.point_tooltip_layout, parentView, false);
        tooltipView.setVisibility(View.INVISIBLE);

        ImageView imageView = tooltipView.findViewById(R.id.tooltipImage);
        imageView.setImageResource(drawableRes);
        parentView.addView(tooltipView);
    }

    @Override
    public void onDataPointTouch(float x, float y) {

    }

    @Override
    public void onDataPointClick(float x, float y) {
        tooltipView.setVisibility(View.VISIBLE);
        tooltipView.setX(x - tooltipView.getWidth() / 2);
        tooltipView.setY(y - tooltipView.getHeight() / 2);
    }
}
